import React from 'react';
import {
  ToolboxPlugin,
  ContextMenuPlugin,
  SavePlugin,
  PropertiesPlugin,
  ExportPlugin,
  ImportPlugin,
  PreviewPlugin,
} from '@design/core';
import { saveMobileForm } from '@service/form';
import RenderPlugin from './render';
import FormPlugin from './form';
// import { ToolboxButton, toolboxOptions } from './toolbox/index';
import ContextMenuOptions from './contextmenu';
import Preview from '../components/Preview';

const ref = React.createRef();
const previewRef = React.createRef();
function ReactPlugin(options = {}) {
  const { plugins = [] } = options;
  // 控制侧边栏渲染组件
  // let { toolbox = [] } = options;
  // toolbox = toolboxOptions.concat(toolbox);
  return [
    SavePlugin({ save: saveMobileForm }),
    ExportPlugin(),
    ImportPlugin(),
    PreviewPlugin({
      Component: Preview,
      ref: previewRef,
    }),
    ...plugins,
    FormPlugin(),
    ToolboxPlugin({ toolbox: [], ToolboxButton: [] }),
    ContextMenuPlugin(ContextMenuOptions),
    PropertiesPlugin({ ref, tabs: ['property'] }),
    RenderPlugin(),
  ];
}

export default ReactPlugin;
